package com.jfree.zk.test;

import org.springframework.context.annotation.Conditional;
import sun.misc.BASE64Encoder;

import java.io.*;
import java.util.Base64;
import java.util.Scanner;

/**
 * @author wangjian
 * @date 2019/7/17 14:21
 */
public class Main {


    public static void main(String[] args) throws Exception {
        File file = new File("C:\\Users\\YCKJ2201\\Desktop\\jfree\\video.mp4");
        String str = ioToBase64(new FileInputStream(file));
        FileWriter fileWriter = null;
        str = str.replaceAll("\r\n", "");
        fileWriter = new FileWriter("C:\\Users\\YCKJ2201\\Desktop\\jfree\\video.txt", true);
        fileWriter.write(str);
        fileWriter.close();
    }

    public static String ioToBase64(InputStream in) throws Exception {
        String strBase64 = null;
        try {
            byte[] bytes = new byte[in.available()];
            in.read(bytes);
            strBase64 = new BASE64Encoder().encode(bytes);
            in.close();
        } catch (Exception e) {
        }
        return strBase64;
    }

}
